<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="dragon.core.system.po.SysUser"%>
<%@ include file="../../../taglib.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%
	List<SysUser> glist = (List<SysUser>) request.getAttribute("glist");
	List<SysUser> slist = (List<SysUser>) request.getAttribute("slist");
	String gid = (String) request.getAttribute("gid");
	SysUser M = null;
	SysUser S = null;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<title>用户组</title>
<link rel="stylesheet" type="text/css" href="css/dialog.css" />
<%@ include file="/webmodules/console/css.jsp"%>
<%@ include file="/webmodules/console/js.jsp"%>
<script type="text/javascript">
    function addgu(uid,gid){
    	$.post("dragon/modules/system/user/action/UserGroupHandler/addGroupUser.ejw",{uid:uid,gid:gid},function(data){
    		if(data.result !=undefined && data.result == true){
    			 $("#"+uid+" img").remove();
                 var string = "<div id='"+uid+"'>"+$("#"+uid).html()+"<img style='cursor: pointer;' src='img/delgu.gif' onclick='delgu("+uid+","+gid+");' /></div>";
                 $("#"+uid).remove();
                 $("#nowuser").html($("#nowuser").html()+string);
			}
			if(data.MESSAGE_ERROR != undefined && data.MESSAGE_ERROR != ''){
				top.showMsg("错误", data.MESSAGE_ERROR, true,'error');
			}else if(data.MESSAGE_WARNING != undefined && data.MESSAGE_WARNING != ''){
				top.showMsg("警告", data.MESSAGE_WARNING, true,'warning');
			}else if(data.MESSAGE_INFO != undefined && data.MESSAGE_INFO != ''){
				top.showMsg("", data.MESSAGE_INFO, false);
			}
    	},'json');
    	
    }
    function delgu(uid,gid){
    	$.post("dragon/modules/system/user/action/UserGroupHandler/delGroupUser.ejw",{uid:uid,gid:gid},function(data){
    		if(data.result !=undefined && data.result == true){
    			 $("#"+uid+" img").remove();
                 var string = "<div id='"+uid+"'>"+"<img style='cursor: pointer;' src='img/addgu.gif' onclick='addgu("+uid+","+gid+");' />"+$("#"+uid).html()+"</div>";
                 $("#"+uid).remove();
                 $("#alluser").html($("#alluser").html()+string);
                
			}
			if(data.MESSAGE_ERROR != undefined && data.MESSAGE_ERROR != ''){
				top.showMsg("错误", data.MESSAGE_ERROR, true,'error');
			}else if(data.MESSAGE_WARNING != undefined && data.MESSAGE_WARNING != ''){
				top.showMsg("警告", data.MESSAGE_WARNING, true,'warning');
			}else if(data.MESSAGE_INFO != undefined && data.MESSAGE_INFO != ''){
				top.showMsg("", data.MESSAGE_INFO, false);
			}
    	},'json');
    	
    }
    </script>
</head>
<body>
	<div style="width: 550px; height: 260px;">
		<div style="width: 99%; margin: 0, auto;">
			<div style="width: 49%; text-align: center; float: left; color: #2B6FAD; font-size: 14px;">当前组用户</div>
			<div style="width: 49%; text-align: center; float: left; color: #2B6FAD; font-size: 14px;">可选用户</div>
		</div>
		<div style="width: 270px; height: 350px; float: left; overflow: scroll; overflow-x: hidden; font-size: 13px;" id="nowuser">
			<%
				for (int i = 0; i < glist.size(); i++) {
					M = glist.get(i);
			%>
			<div style="width: 230px" id="<%=M.getId()%>"><%=M.getLoginname() + "|" + M.getUsername()%><img style="cursor: pointer;" src="img/delgu.gif" onclick="delgu(<%=M.getId() + "," + gid%>);" />
			</div>
			<%
				}
			%>
		</div>
		<div style="width: 270px; height: 350px; float: right; border-left: 1px dashed #28A0D5; overflow: scroll; overflow-x: hidden; font-size: 13px;" id="alluser">
			<%
				for (int i = 0; i < slist.size(); i++) {
					S = slist.get(i);
			%>
			<div style="width: 230px" id="<%=S.getId()%>">
				<img style="cursor: pointer;" src="img/addgu.gif" onclick="addgu(<%=S.getId() + "," + gid%>);" /><%=S.getLoginname() + "|" + S.getUsername()%></div>
			<%
				}
			%>
		</div>
	</div>
</body>
</html>
